package com.liaoye.hellocustomview.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatTextView;

import com.liaoye.hellocustomview.listener.MyGestureListener;

public class MyGestureTextView extends AppCompatTextView{

    private GestureDetector mGestureDetector;

    {
        mGestureDetector = new GestureDetector(getContext(), new MyGestureListener());
        setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return mGestureDetector.onTouchEvent(event);
            }
        });
        setFocusable(true);
        setClickable(true);
        setLongClickable(true);
    }

    public MyGestureTextView(Context context) {
        super(context);
    }

    public MyGestureTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyGestureTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

}
